﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>

    $(function () {

        var mydate = new Date();
        $("#end").val(formatDate(mydate));
        mydate.setDate(mydate.getDate());
        $("#start").val(formatDate(mydate));
        initControl();

        gridList();
    });

    var oMenuIcon;
    function gridList() {
        var $gridList = $("#gridList");
        $.ajax({
            type: 'get',
            datatype: "json",
            url: "/SystemManage/SysUser/GetDictionaryJson",
            success: function (data) {
                var userData = JSON.parse(data);
                $.ajax({
                    type: 'get',
                    datatype: "json",
                    url: "/SystemManage/SysOperationLog/GetModuleDictionaryJson",
                    success: function (moduleda) {
                        var moduledata = JSON.parse(moduleda);
                        $gridList.dataGrid({
                            url: "/SystemManage/SysOperationLog/GetGridPaginationJson",
                            postData: { userId: $("#UserId").select2().val(), start: $("#start").val(), end: $("#end").val() },
                            height: $(window).height() - 120,
                            colModel: [
                                { label: '操作时间', name: 'CreatorTime', width: 130, align: 'left' },
                                {
                                    label: '操作用户', name: 'CreatorUserId', width: 120, align: 'left', formatter: function (cellvalue) {
                                        return userData[cellvalue] == null ? "" : userData[cellvalue].fullname;
                                    }
                                },
                                //{ label: '类型', name: 'Type', width: 60, align: 'left' },
                               
                               // { label: '浏览器', name: 'Browser', width: 80, align: 'left' },
                              


                               {
                                   label: '系统模块', name: 'ModuleId', width: 100, align: 'left', formatter: function (cellvalue, options, rowObject) {

                                       return moduledata[cellvalue] == null ? "" : moduledata[cellvalue].FullName;

                                   }

                               },

                                 {
                                     label: '系统模块', name: 'AuthorizeId', width: 100, align: 'left', formatter: function (cellvalue, options, rowObject) {

                                         return moduledata[cellvalue] == null ? "" : moduledata[cellvalue].FullName;

                                     }

                                },
                                { label: '用户IP', name: 'IpAddress', width: 100, align: 'left' },
                                { label: '浏览器', name: 'UserAgent', width: 200, align: 'left' },
                                { label: '请求方式', name: 'RequestType', width: 60, align: 'left' },
                                { label: 'Url地址', name: 'Url', width: 360, align: 'left' },
                               // { label: '操作内容', name: 'OperationCon', width: 100, align: 'left' },
                                {
                                    label: '结果', name: 'Result', width: 100, align: 'left', formatter: function (cellvalue) {
                                        if (cellvalue === true) {
                                            return "成功";
                                        } else {
                                            return "失败";
                                        }
                                    }
                                },
                                { label: '描述', name: 'Description', width: 100, align: 'left' },

                                { label: "主键", name: "Id", hidden: true, key: true }
                            ],
                            pager: "#gridPager",
                            sortname: 'CreatorTime desc',
                            rowNum: 20,
                            rowList: [20, 50, 100, 200],
                            viewrecords: true
                        });

                    }
                });
            }
        });
        $("#btn_search").click(function () {
            //alert($("#UserId").select2().val());
            $gridList.jqGrid('setGridParam', {
                postData: {
                    userId: $("#UserId").select2().val(),
                    start: $("#start").val(),
                    end: $("#end").val()
                }
            }).trigger('reloadGrid');


        });
    }
    function initControl() {
        $.ajax({
            url: "/SystemManage/SysUser/GetTreeSelectBusinessJson",
            dataType: "json",
            async: false,
            success: function (data) {
                $("#UserId").select2({
                    data: data,
                    placeholder: '请选择用户'
                });
            }
        });

        $("#UserId").on("select2:select", function (e) {

            //  alert($("#UserId").select2().val());

            //GetExtendedPropertyInit(oMenuIcon.val(), "{}");
        });

    }

    //function btn_delete() {
    //    $.deleteForm({
    //        url: "/SystemManage/SysOperationLog/DeleteForm",
    //        param: { keyValue: $("#gridList").jqGridRowValue().Id },
    //        success: function () {
    //            $("#gridList").trigger("reloadGrid");
    //        }
    //    });
    //}

</script>
<div class="topPanel">
    <div class="toolbar">
        @*<div class="btn-group">
                <a id="NF-add" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-plus"></i>新建</a>
            </div>*@
        <div class="operate">
            <ul class="nav nav-pills">
                <li class="first">已选中<span>1</span>项</li>
                <li><a id="NF-edit" authorize="yes" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>修改</a></li>
                <li><a id="NF-delete" authorize="yes" onclick="btn_delete()"><i class="fa fa-trash-o"></i>删除</a></li>
                <li><a id="NF-Details" authorize="yes" onclick="btn_details()"><i class="fa fa-search-plus"></i>查看</a></li>
            </ul>
            <a href="javascript:;" class="close"></a>
        </div>
        <script>$('.toolbar').authorizeButton()</script>
    </div>
    <div class="search">


        <table>
            <tbody>
                <tr>
                    <td>
                        <div class="input-group">
                            <select id="UserId" name="UserId" class="form-control" placeholder="请选择用户" >
                                <option value="">请选择用户</option>
                            </select>
                        </div>
                        @*<div id="txt_condition" class="btn-group">
                            <a class="btn btn-default dropdown-text" data-toggle="dropdown">选择条件</a>
                            <a class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></a>
                            <ul class="dropdown-menu">*@
                        @*<li><a href="javascript:void()" data-value="DbName">选择条件</a></li>
                            <li><a href="javascript:void()" data-value="DbName">错误</a></li>
                            <li><a href="javascript:void()" data-value="FileName">调试</a></li>
                            <li><a href="javascript:void()" data-value="FileName">警告</a></li>*@
                        @*</ul>
                            </div>*@
                    </td>
                    <td style="padding-left: 10px;">
                        <div class="input-group">
                            <input class="form-control" id="start" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" placeholder="开始时间" style=" width:100px" type="text">
                        </div>
                    </td>
                    <td style="padding-left: 10px;">
                        <div class="input-group">
                            <input class="form-control" id="end" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" placeholder="结束时间" style=" width:100px" type="text">
                        </div>
                    </td>
                    <td style="padding-left: 10px;">
                        <div class="input-group">
                            <span class="input-group-btn">
                                <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                            </span>
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>

        @*<table>
                <tr>
                    <td>
                        <div class="input-group">
                            <input id="txt_keyword" type="text" class="form-control" placeholder="请输入要查询关键字" style="width: 200px;">
                            <span class="input-group-btn">
                                <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                            </span>
                        </div>
                    </td>
                </tr>
            </table>*@
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>




